<?php
include_once('include/Config.php');

class LocalidadDAL{

    private $link;

    function __construct() {
        $this->conectar();
    }

    function conectar() {
        
        //Tomado del config.php 
        $this->link = $GLOBALS["DBConnPDO"];
        
    }
    
    function comboLocalidad(){
        $query = "SELECT idProvincia, idLocalidad, Descripcion FROM localidad";
        
        $result = '';
        
        foreach ($this->link->query($query) as $row) {
            $result .= $row['idProvincia'].'-'.$row['idLocalidad'].':'.$row['Descripcion'].';';
        }
        
        if($result != null || $result != ''){
            $result = trim($result, ';');
        }
        
        return $result;
    }
    
    
    function comboLocalidadHTML(){
        $query = "SELECT idProvincia, idLocalidad, Descripcion FROM localidad";
        
        $result = '';
        
        foreach ($this->link->query($query) as $row) {
            $result .= '<OPTION VALUE="' . $row['idProvincia'].'-'.$row['idLocalidad'] . '">' . $row['Descripcion'] . '</OPTION>';
        }
        
        return $result;
    }    
}
?>